<template>

  <div class="pb50">
    <el-form size="small" ref="form" :model="form" label-width="100px">
      <el-form-item label="開啟erp推送" prop="isOpenErp">
        <el-switch v-model="form.isOpenErp"></el-switch>
      </el-form-item>
      <div >
        <el-form-item
            label="appkey"
            prop="jjyAppkey"
        >
          <el-input
              class="max-w460"
              v-model="form.jjyAppkey"
              placeholder=""
              type="text"
          ></el-input>
        </el-form-item>

        <el-form-item
            label="secret"
            prop="jjySecret"
        >
          <el-input
              class="max-w460"
              v-model="form.jjySecret"
              placeholder=""
              type="text"
          ></el-input>
        </el-form-item>

        <el-form-item
            label="公鑰"
            prop="jjyPublickey"
        >
          <el-input
              class="max-w460"
              v-model="form.jjyPublickey"
              placeholder=""
              type="text"
          ></el-input>
        </el-form-item>

        <el-form-item
            label="私鑰"
            prop="jjyPrivatekey"
        >
          <el-input
              class="max-w460"
              v-model="form.jjyPrivatekey"
              placeholder=""
              type="text"
          ></el-input>
        </el-form-item>

        <el-form-item
            label="網域名稱"
            prop="jjyUrl"
        >
          <el-input
              class="max-w460"
              v-model="form.jjyUrl"
              placeholder=""
              type="text"
          ></el-input>
        </el-form-item>


      </div>
      <!--提交-->
      <div class="common-button-wrapper">
        <el-button
          size="small"
          type="primary"
          @click="onSubmit"
          :loading="loading"
          >提交</el-button
        >
      </div>
    </el-form>
  </div>
</template>

<script>
import JiujiuyunErpApi from "@/api/jiujiuyunerp.js";
export default {
  components: {},
  data() {
    return {
      form: {
        isOpenErp: false,
        jjyAppkey: "",
        jjySecret: "",
        jjyPublickey: "",
        jjyPrivatekey: "",
        jjyUrl: ""
      },
      /*是否加载完成*/
      loading: false
    };
  },
  created() {
    this.getData();
  },
  methods: {
    /*获取数据*/
    getData() {
      let self = this;
      JiujiuyunErpApi.getData().then(res => {
        self.form = res.data;
      }).catch(error => {});
    },
    /*提交*/
    onSubmit() {
      let self = this;
      let params = self.form;
      self.loading = true;
      JiujiuyunErpApi.saveData(params, true).then(data => {
        self.loading = false;
        if (data.code == 1) {
          ElMessage({
            message: "恭喜您，儲存成功",
            type: "success"
          });
          self.getData();
        }
      }).catch(error => {
        self.loading = false;
      });
    }
  }
};
</script>

<style>
.reward-list .reward-item {
  margin-bottom: 10px;
  padding: 10px 20px;
  border: 1px solid #ebeef5;
}

.reward-list .delete-reward {
  position: absolute;
  top: 10px;
  right: 20px;
  cursor: pointer;
  z-index: 10;
}
</style>

